<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>LTPP在线开发社区直播课堂</title>
    <link href="/videojs.css" rel="stylesheet">
    <script src="/video.js" type="text/javascript"></script>
    <script src="/videojs.js" type="text/javascript"></script>
    <!-- videojs-contrib-hls 用于在电脑端播放 如果只需手机播放可以不引入 -->
</head>
<style>
    body {
        background-color: rgb(209, 209, 190);
    }
</style>

<body>
    <style>
        .video-js .vjs-tech {
            position: relative !important;
        }
    </style>
    <div>
        <video id="myVideo" class="video-js vjs-default-skin vjs-big-play-centered" controls preload="auto" data-setup='{}' style='width: 100%;height: auto'>
            <source id="source" src="http://bofang.sqsjjy.top/live/LTPP.m3u8" type="application/x-mpegURL"></source>
        </video>
    </div>
</body>

<script>
    // videojs 简单使用
    var myVideo = videojs('myVideo', {
        bigPlayButton: true,
        textTrackDisplay: false,
        posterImage: false,
        errorDisplay: false,
    })
    myVideo.play()
    var changeVideo = function(vdoSrc) {
        if (/\.m3u8$/.test(vdoSrc)) { //判断视频源是否是m3u8的格式
            myVideo.src({
                src: vdoSrc,
                type: 'application/x-mpegURL' //在重新添加视频源的时候需要给新的type的值
            })
        } else {
            myVideo.src(vdoSrc)
        }
        myVideo.load();
        myVideo.play();
    }
</script>

</html>